package indiwood.model.dao;

import indiwood.model.ProductionCommentVO;
import indiwood.model.ProductionVO;

import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;
@Repository
public class ProductionDAOImpl implements ProductionDAO {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;	
	@Override
	public List<ProductionVO> productionList(String pageNo){
		return sqlSessionTemplate.selectList("production.productionList", pageNo);
	}
	@Override
	public int write(ProductionVO pvo){
		return (Integer)sqlSessionTemplate.insert("production.write",pvo);
	}
	@Override
	public int totalContent(){
	return sqlSessionTemplate.selectOne("production.totalContent");
	}
	@Override
	public void updateCount(int productionNo){
		sqlSessionTemplate.update("production.updateCount",productionNo);
	}
	@Override
	public void deleteBoard(String productionNo){
		sqlSessionTemplate.delete("production.deleteBoard", productionNo);
	}
	@Override
	public void updateBoard(ProductionVO pvo){
		sqlSessionTemplate.update("production.updateBoard", pvo);
	}
	@Override
	public int commentWrite(ProductionCommentVO pcvo) {
		return (Integer)sqlSessionTemplate.insert("production.commentWrite",pcvo);
	}
	/*@Override
	public List<ProductionCommentVO> productionCommentList(String pageNo) {
		return sqlSessionTemplate.selectList("production.productionCommentList", pageNo);
	}*/
	public ProductionVO content(int productionNo){
		return sqlSessionTemplate.selectOne("production.content",productionNo);
	}
	public List<ProductionCommentVO> productionCommentList(int productionNo){
		return sqlSessionTemplate.selectList("production.commentList",productionNo);
	}
	@Override
	public void deleteComment(String productionCommentNo) {
		sqlSessionTemplate.delete("production.deleteComment", productionCommentNo);
	}
}
